<template>
	<view class="container">
		<block v-if="isload">
			<!-- #ifndef H5 || APP-PLUS -->
			<view class="topsearch flex-y-center">
				<view class="f1 flex-y-center">
					<image class="img" src="/static/img/search_ico.png"></image>
					<input :value="keyword" placeholder="输入关键字搜索" placeholder-style="font-size:24rpx;color:#C2C2C2"
						@confirm="searchConfirm"></input>
				</view>
			</view>
			<!--  #endif -->
			<view class="content" id="datalist">
				<block v-for="(item, index) in datalist" :key="index">
					<view class="item" @tap="gotod(item)" >
						<view class="f1">
							<text class="t2">订单编号：{{item.ordernum}}</text>
							<text class="t2">支付类型：{{item.paytypestr}}</text> 
							<text class="t2">支付项目：{{item.title}}</text>
							<text class="t2">支付数量：{{item.num}}</text>
							<text class="t2">支付方式：{{item.paytype}}</text> 
							<text class="t2">付款时间：{{item.paytime}}</text> 
						</view>
						<view class="f2">
							<text class="t1">￥{{item.money}}</text>
						</view>
					</view>
				</block>
			</view>
		</block>
		<nodata v-if="nodata"></nodata>
		<nomore v-if="nomore"></nomore>
		<loading v-if="loading"></loading>
		<dp-tabbar :opt="opt"></dp-tabbar>
		<popmsg ref="popmsg"></popmsg>
	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				opt: {},
				loading: false,
				isload: false,
				menuindex: -1,

				st: 0,
				datalist: [],
				pagenum: 1,
				nodata: false,
				nomore: false,
				keyword: '',
			};
		},

		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			this.getdata();
		},
		onPullDownRefresh: function() {
			this.getdata();
		},
		onReachBottom: function() {
			if (!this.nodata && !this.nomore) {
				this.pagenum = this.pagenum + 1;
				this.getdata(true);
			}
		},
		onNavigationBarSearchInputConfirmed: function(e) {
			this.searchConfirm({
				detail: {
					value: e.text
				}
			});
		},
		methods: {
			getdata: function(loadmore) {
				if (!loadmore) {
					this.pagenum = 1;
					this.datalist = [];
				}
				var that = this;
				var pagenum = that.pagenum;
				var st = that.st;
				this.nodata = false;
				this.nomore = false;
				this.loading = true;
				app.post('My/payorderlog', {
					st: st,
					pagenum: pagenum,
					keyword: that.keyword
				}, function(res) {
					that.loading = false;
					var data = res.data;
					if (pagenum == 1) {
						that.datalist = data;
						if (data.length == 0) {
							that.nodata = true;
						}
						that.loaded();
					} else {
						if (data.length == 0) {
							that.nomore = true;
						} else {
							var datalist = that.datalist;
							var newdata = datalist.concat(data);
							that.datalist = newdata;
						}
					}
				});
			},
			changetab: function(e) {
				var st = e.currentTarget.dataset.st;
				this.st = st;
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				this.getdata();
			},
			searchConfirm: function(e) {
				this.keyword = e.detail.value;
				this.getdata(false);
			},
			gotod(item){
				if(item.type=='facepay'){
					uni.navigateTo({
						url:"/pages/facepay/facepaydetail?id="+item.orderid
					})
				}else if(item.type=='shop'){
					uni.navigateTo({
						url:"/pagesExt/order/detail?id="+item.orderid
					})
				}else if(item.type=='groupby'){
					uni.navigateTo({
						url:"/pagesExt/groupby/orderdetail?id="+item.orderid
					})
				}else if(item.type=='seckill'){
					uni.navigateTo({
						url:"/pagesExt/seckill/orderdetail?id="+item.orderid
					})
				}
			}
		}
	};
</script>
<style>
	.topsearch {
		width: 94%;
		margin: 10rpx 3%;
	}

	.topsearch .f1 {
		height: 60rpx;
		border-radius: 30rpx;
		border: 0;
		background-color: #fff;
		flex: 1
	}

	.topsearch .f1 .img {
		width: 24rpx;
		height: 24rpx;
		margin-left: 10px
	}

	.topsearch .f1 input {
		height: 100%;
		flex: 1;
		padding: 0 20rpx;
		font-size: 28rpx;
		color: #333;
	}

	.content {
		width: 94%;
		margin: 0 3%;
	}

	.content .item {
		width: 100%;
		margin: 20rpx 0;
		background: #fff;
		border-radius: 5px;
		padding: 20rpx 20rpx;
		display: flex;
		align-items: center
	}

	.content .item:last-child {
		border: 0
	}

	.content .item .f1 {
		flex: 1;
		display: flex;
		flex-direction: column
	}

	.content .item .f1 .t1 {
		color: #000000;
		font-size: 32rpx;
		height: 50rpx;
		line-height: 50rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.content .item .f1 .t2 {
		color: #666666
	}

	.content .item .f1 .t3 {
		color: #666666
	}

	.content .item .f2 {
		font-size: 36rpx;
		text-align: right
	}

	.content .item .f2 .t1 {
		color: #FD4A46
	}

	.content .item .f2 .t2 {
		color: #000000
	}

	.content .item .f3 {
		flex: 1;
		font-size: 32rpx;
		text-align: right
	}

	.content .item .f3 .t1 {
		color: #FD4A46
	}

	.content .item .f3 .t2 {
		color: #000000
	}
</style>